package 动态链表.约瑟夫环;

import 动态链表.LinkedSinglyCircularList;

public class TestJosePhusLoop {
    public static void main(String[] args) {
        LinkedSinglyCircularList<Integer> list = new LinkedSinglyCircularList<>();
        for (int i = 1; i <= 41; i++) {
            list.add(i);
        }
        System.out.println(list);
//        list.josephusLoop();
        int p = 0;
        while (list.size() != 2){
            p = (p + 2) % list.size();
            list.remove(p);
        }
        System.out.println(list);
    }
}
